<?php
class BuyOrderInfoModel extends Db {
	private $_buy_info = 'd_buy_info';
	
	public function addGoods($params) {
		return $this->add ( $this->_buy_info, $params );
	}
	
	public function getGoodsBySNO($sno) {
		return $this->getAll ( $this->_buy_info, array ('orderno' => $sno ) );
	}
	
	public function saveSnapshotById($snapshot, $id) {
		return $this->update ( $this->_buy_info, array ('snapshot' => $snapshot ), array ('id' => $id ) );
	}
	
	public function getGoodsById($id) {
		return $this->getOne ( $this->_buy_info, array ('id' => $id ) );
	}
	
	public function setOrderInfoSNOBySNO($newsno, $oldsno) {
		return $this->update ( $this->_buy_info, array ('orderno' => $newsno ), array ('orderno' => $oldsno ) );
	}
	
	public function setOrderInfoByID($v, $id) {
		return $this->update ( $this->_buy_info, $v, array ('id' => $id ) );
	}
	
	public function delOrderGoodsById($id) {
		return $this->delete ( $this->_buy_info, array ('id' => $id ) );
	}
	
	/**
	 * 
	 * @return BuyOrderInfoModel
	 */
	public static function instance() {
		return parent::_instance ( __CLASS__ );
	}

}